Skip to content

添加受保护路径 - ProtectFileAddProtectedPath

函数简介

添加受保护路径。(高级版功能,普通版无法使用)

接口名称

ProtectFileAddProtectedPath

DLL调用

c
int32_t ProtectFileAddProtectedPath(int64_t instance, string path, int32_t mode, int32_t is_directory);

参数说明

参数名类型说明
instance长整数型OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。
path字符串要保护的文件或文件夹路径。
mode整数型保护模式:0-全部拦截(不参考白名单),1-允许白名单(只允许白名单的进程访问),2-黑名单拦截(只拦截指定黑名单进程)。
is_directory整数型是否为目录(1 目录,0 文件)。

示例

SDK 调用

cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
int ret = ola.ProtectFileAddProtectedPath("C:\\test.txt", 0, 0);
if (ret == 1) {
    // 操作成功
}
csharp
using OLAPlug;

var ola = new OLAPlugServer();
int ret = ola.ProtectFileAddProtectedPath("C:\\test.txt", 0, 0);
if (ret == 1)
{
    // 操作成功
}
python
from OLAPlugServer import OLAPlugServer

ola = OLAPlugServer()
ret = ola.ProtectFileAddProtectedPath("C:\\test.txt", 0, 0)
if ret == 1:
    pass  # 操作成功
java
import com.olaplug.OLAPlugServer;

OLAPlugServer ola = new OLAPlugServer();
int ret = ola.ProtectFileAddProtectedPath("C:\\test.txt", 0, 0);
if (ret == 1) {
    // 操作成功
}
cpp
var ola = com("OlaPlug.OlaSoft")
var ret = ola.ProtectFileAddProtectedPath("C:\\test.txt", 0, 0)
if(ret == 1) {
    // 操作成功
}
vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
ret = ola.ProtectFileAddProtectedPath("C:\\test.txt", 0, 0)
If ret = 1 Then
    ' 操作成功
End If
text
.局部变量 ola, OLAPlug
ola.创建 ()
ret = ola.ProtectFileAddProtectedPath(“C:\\test.txt”, 0, 0)
.如果真 (ret = 1)
    ' 操作成功
.如果真结束
aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var ret = ola.ProtectFileAddProtectedPath("C:\\test.txt", 0, 0);
if(ret == 1){
    // 操作成功
}
text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
整数 ret = ola.ProtectFileAddProtectedPath("C:\\test.txt", 0, 0)
如果真 (ret = 1)
{
    // 操作成功
}
cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
int32_t ret = ola.ProtectFileAddProtectedPath("C:\\test.txt", 0, 0);
if (ret == 1) {
    // 操作成功
}

原生 DLL 调用

cpp
ProtectFileAddProtectedPath(instance, "C:\\test.txt", 0, 0);
csharp
using System.Runtime.InteropServices;
using System.Text;

[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int ProtectFileAddProtectedPath(long ola, string path, int mode, int is_directory);

ProtectFileAddProtectedPath(instance, "C:\\test.txt", 0, 0);
python
from ctypes import CDLL, c_int, c_int64, create_string_buffer

ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
ola.ProtectFileAddProtectedPath(instance, "C:\\test.txt", 0, 0)

返回值

1 成功,0 失败。

注意事项

  • 需要驱动支持与管理员权限。
  • 保护模式:0-全部拦截,1-允许白名单,2-拦截黑名单。